// by Jens Schmidt 2009
// for: YOU
// use, modify, copy this as you like

function PreferencesAssistant(aSettings) {
	  this.settings=aSettings;
}

PreferencesAssistant.prototype.setup = function() {
	this.controller.setupWidget("userName",
         this.attributes = {
             hintText: $L('your account login name'),
             multiline: false,
             enterSubmits: false,
             focus: true,
			 focusMode: Mojo.Widget.focusSelectMode,
			 maxLength: 30,
			 width: 125
         },
         this.model = {
             value: this.settings.Name,
             disabled: false
    });
	
	this.controller.setupWidget("pass",
         this.attributes = {
             hintText: $L('Type Password'),
             multiline: false,
             enterSubmits: false,
			 focusMode: Mojo.Widget.focusSelectMode,
			 maxLength: 32,
			 width: 125
         },
         this.model = {
             value: this.settings.Pass
    });
/*
 * not yet
	this.controller.setupWidget("TrackPositionToggleButton",
         this.attributes = {
             trueValue: 'On',
             falseValue: 'Off' 
         },
         this.model = {
             value: this.settings.GpsTracking,
             disabled: false
         });
	Mojo.Event.listen(this.controller.get("TrackPositionToggleButton"), Mojo.Event.propertyChange, this.toggleTracking.bind(this));
*/
	this.controller.setupWidget(Mojo.Menu.appMenu,
       	this.attributes = {
                omitDefaultItems: true
            },
    	this.model = {
        visible: true,
        items: [Mojo.Menu.editItem]
		});
}
/*
PreferencesAssistant.prototype.toggleTracking = function(event){
	this.settings.GpsTracking=event.model.value;
	if (event.model.value == 'On') {
		this.controller.showAlertDialog({
			title: $L("GPS Tracking enabled"),
			message: $L("If tracking Position tracking is activated the position retrieved by loc-me-up will be uploaded to Locr."),
			choices: [{
				label: $L("Cool!"),
				value: "cancel",
				type: 'dismiss'
			}]
		});
	}
}
*/

PreferencesAssistant.prototype.activate = function(event) {
}


PreferencesAssistant.prototype.deactivate = function(event) {
}

PreferencesAssistant.prototype.cleanup = function(event) {
    this.settings.loginSet(this.controller.get("userName").mojo.getValue(),
		this.controller.get("pass").mojo.getValue());
}
